<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use App;

class PaylogModel extends Model
{
    protected $table = 'paylog';

    protected $guarded = [
        'id'
    ];

    public function seller()
    {
        return $this->belongsTo(Seller::class, 'seller_id', 'id');
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }


    public function relate()
    {

        switch($this->getAttribute('relate_type')) {
            case App\Constant::PAYLOG_TYPE_RECHARGE :
                return $this->belongsTo(Wallet::class, 'relate_id', 'id');
                break;
            case App\Constant::PAYLOG_TYPE_ORDER :
                break;
            case App\Constant::PAYLOG_TYPE_DEPOSIT :
                return $this->belongsTo(Wallet::class, 'relate_id', 'id');
                break;
        }
    }

}
